﻿using AutoMapper;
using J.Status.Application.Command.RoomNumCommand;
using J.StatusModel;
using MediatR;
using StatusService;

namespace J.Status.Application.Handler.RoomNumHandler
{
    public class RoomNumCreateHandler : IRequestHandler<RoomNumCreateCommand, int>
    {
        private readonly IRoomNumManageService roomNumManageService;
        private readonly IMapper mapper;
        public RoomNumCreateHandler(IRoomNumManageService roomNumManageService,IMapper mapper)
        {
            this.mapper = mapper;
            this.roomNumManageService = roomNumManageService;
        }

        public async Task<int> Handle(RoomNumCreateCommand request, CancellationToken cancellationToken)
        {
            RoomNumManage model= mapper.Map<RoomNumManage>(request);
            return await roomNumManageService.RoomNumAdd(model);
        }
    }
}
